package com.middlegroup.pay.service.impl;

import com.middlegroup.pay.entity.Merchant;
import com.middlegroup.pay.mapper.MerchantMapper;
import com.middlegroup.pay.service.MerchantService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 商户表 服务实现类
 * </p>
 *
 * @author pc123
 * @since 2019-01-04
 */
@Service
public class MerchantServiceImpl extends ServiceImpl<MerchantMapper, Merchant> implements MerchantService {

    @Resource
    private MerchantMapper merchantMapper;

    @Override
    @Cacheable(value = "pay_platform",key = "'merchant'+#p0.toString()",unless = "#result eq null")
    public Merchant getMerchantByCode(String code) {
        return merchantMapper.getMerchantByCode(code);
    }

    @Override
    @CachePut(value = "pay_platform",key = "'merchant'+#p0.toString()",unless = "#result eq null")
    public Merchant refreshMerchantByCode(String code) {
        return merchantMapper.getMerchantByCode(code);
    }

    @Override
    public void refreshMerchant() {
    }
}
